/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.config.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.common.seal.dto.SealInfoRequest;
import com.icinfo.cloud.provider.punish.common.seal.dto.SealPreviewInfoRequest;
import com.icinfo.cloud.provider.punish.common.seal.vo.ConfigOrgRelatedSealVo;
import com.icinfo.cloud.provider.punish.config.service.IConfigOrgRelatedSealService;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 描述: 机构印章关联配置表 config_org_related_seal 对应的Controller类.<br>
 *
 * @author framework generator
 * @date 2022年03月02日
 */
@RestController
@RefreshScope
@RequestMapping("/punish/config/org/related/seal")
@Slf4j
public class ConfigOrgRelatedSealController extends BaseController {

    @Resource
    private IConfigOrgRelatedSealService configOrgRelatedSealService;


    /**
     * 【V1.0.0】描述：根据机构统一社会信用代码查询机构关联印章配置信息
     *
     * @param uniscid 机构统一社会信用代码
     * @return {@link Result<ConfigOrgRelatedSealVo>} 机构关联印章配置信息
     * @author xiangyuyu
     * @date 2022-03-02 19:10
     */
    @PostMapping("/getOrgRelatedSealConfigInfo")
    @ApiOperation(value = "【V1.0.0】描述：根据机构统一社会信用代码查询机构关联印章配置信息", httpMethod = "POST")
    public Result<ConfigOrgRelatedSealVo> getOrgRelatedSealConfigInfo(@RequestParam String uniscid) {
        ConfigOrgRelatedSealVo vo = configOrgRelatedSealService.getOrgRelatedSealConfigInfo(uniscid,"");
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }
    /**
     * 获取印章信息
     * @author liyafeng
     * @date 2023/7/20
      * @param request
     * @return {@link Result< ConfigOrgRelatedSealVo>}
     */
    @PostMapping("/getOrgRelatedSealConfigInfoByUniscidAndDeptCode")
    public Result<ConfigOrgRelatedSealVo> getOrgRelatedSealConfigInfoByUniscidAndDeptCode(@RequestBody @Validated SealInfoRequest request) {
        ConfigOrgRelatedSealVo vo = configOrgRelatedSealService.getOrgRelatedSealConfigInfo(request.getUniscid(),request.getDeptCode());
        return Result.success(Constant.STRING_GET_SUCCESS, vo);
    }

    /**
     * 【V2.0.0】描述：获取印章预览信息
     *
     * @param request {@link SealPreviewInfoRequest}
     * @return {@link Result<String>} 印章图片互联网地址
     * @author xiangyuyu
     * @date 2022-05-16 16:16
     */
    @PostMapping("/getSealPreviewInfo")
    @ApiOperation(value = "【V2.0.0】描述：获取印章预览信息", httpMethod = "POST")
    public Result<String> getSealPreviewInfo(@RequestBody @Validated SealPreviewInfoRequest request) {
        String url = configOrgRelatedSealService.getSealPreviewInfo(request);
        return Result.success(Constant.STRING_GET_SUCCESS, url);
    }
}